<%-- 
    Document   : index
    Created on : Apr 21, 2012, 7:01:58 PM
    Author     : TANGQUOCTUAN
--%>
<%@page import="java.util.ArrayList"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Tunga Restaurant</title>
        <script type="text/javascript">
            function check(){
                var pass = document.getElementById("pass");
                var opass = document.getElementById("opass");
                var npass = document.getElementById("npass");
                var cpass = document.getElementById("cpass");
                var re = /^\w{6,}$/;
                if(opass.value.length==0){
                    alert("This field is required");
                    f.txtOpass.focus();
                    return false;
                }

                if(opass.value!=pass.value){
                    alert("Your old password is wrong.");
                    f.txtOpass.focus();
                    return false;
                }

                if(npass.value.length==0){
                    alert("This field is required");
                    f.txtNpass.focus();
                    return false;
                }

                if(re.test(npass.value)==false){
                    alert("Password must be least at 6 character");
                    f.txtNpass.focus();
                    return false;
                }

                if(cpass.value!=npass.value){
                    alert("Confirm password not compatible");
                    f.txtCpass.focus();
                    return false;
                }
                return true;
            }
        </script>
        <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <center>
            <c:set var="session" value="${sessionScope.user}"/>
            <c:if test="${empty session}">
                <c:redirect url="index.jsp"/>
            </c:if>
            <div class="outer">
                <!--Header end-->
                <div id="rc1"></div>
                <div id="bg">
                    <div class="toplinks"><a href="ContactUs.jsp">Contact us</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="initShowFood?action=Food">Food</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="ControllerTables?action=Table">Table</a></div><div class="sap">|</div>
                    <div class="toplinks"><a href="ControllerRooms?action=Room">Room</a></div><div class="sap">|</div>
                    <c:if test="${empty session}">
                        <div class="toplinks"><a href="registration.jsp">Register</a></div><div class="sap">|</div>
                        <div class="toplinks"><a href="login.jsp">Login</a></div><div class="sap">|</div>
                    </c:if>
                    <div class="toplinks"><a href="index.jsp">Home Page</a></div>
                    <div><font color="white">Welcome, </font><font color="yellow">${sessionScope.user}</font> </div>
                    <div>
                        <font color="yellow"><a href="ControllerCustomer?action=Information&user=${sessionScope.user}">Your information</a></font>
                        <%
                                    if (session.getAttribute("isadmin") != null) {
                        %>
                        <a href="index_admin.jsp">Admin Manager</a>
                        <%                                    }
                        %>
                        <font color="yellow">
                            <c:url var="LogOut" value="ControllerCustomer">
                                <c:param name="action" value="LogOut"/>
                            </c:url>
                            <a href="${LogOut}">LogOut</a>
                        </font>
                    </div>
                </div>
                <div id="rc2"></div>
                <div id="header">
                    <div class="name">Tunga Restaurant</div>
                    <div class="tag">The best restaurant in the world</div>
                </div>
                <!--Top nav end-->
                <div style="clear:left"></div>
                <div id="outer2">
                    <div id="left-nav">
                        <div class="leftlinks">
                            <span class="heading">Quick Links</span>
                            <ul>
                                <li><a href="index.jsp">Home Page </a></li>
                                <li><a href="ControllerRooms?action=Room">Room</a></li>
                                <li><a href="ControllerTables?action=Table">Table</a></li>
                                <li><a href="initShowFood?action=Food">Food</a></li>
                                <c:if test="${not empty session}">
                                    <li><a href="ControllerRooms?action=BookRoom">Book Room</a></li>
                                    <li><a href="ControllerTables?action=BookTable">Book Table </a></li>                                   
                                    <li><a href="addToCart.jsp">Shopping Cart</a></li>
                                </c:if>
                                <li><a href="ContactUs.jsp">Contact Us </a></li>
                            </ul>
                        </div>
                    </div><div class="inner_copy"><div class="inner_copy">All <a href="http://www.magentothemesworld.com" title="Best Magento Templates">premium Magento themes</a> at Magentothemesworld.com!</div></div>
                    <div id="content">
                        <span class="heading">Change Password </span>
                        <div id="main">
                            <c:set var="all" value="${applicationScope.info}"/>
                            <c:if test="${not empty all}">
                                <form action="ControllerCustomer" method="POST" name="f" onsubmit="return check();">
                                    <c:forEach var="rows" items="${all}">
                                        <table border="0" align="center">
                                            <input type="hidden" value="${rows.password}" id="pass" name="txtPass"/>
                                            <input type="hidden" value="${rows.custID}" name="id"/>
                                            <tbody>
                                                <tr>
                                                    <td>Old Password:</td>
                                                    <td><input type="password" name="txtOpass" id="opass"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Create Password:</td>
                                                    <td><input type="password" name="txtNpass" id="npass"/></td>
                                                </tr>
                                                <tr>
                                                    <td>Confirm Password:</td>
                                                    <td><input type="password" name="txtCpass" id="cpass"/></td>
                                                </tr>                                                
                                                <tr>
                                                    <td></td>
                                                    <td><input type="submit" value="Change" name="action" /> <input type="button" value="Cancel" onclick="history.go(-1);"/></td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </c:forEach>
                                </form>
                            </c:if>
                        </div>
                    </div>
                    <div style="clear:left"></div>
                </div>
                <!--Bottom part-->
                <div id="bottom">
                    <div id="footer"><div class="fcenter">GROUP02-F5-10-1009-S1</div></div>
                </div>
            </div>
        </center>
    </body>
</html>
